package leetcode.code;

import leetcode.IDebug;

public class Solution492 implements IDebug {

	public int[] constructRectangle2(int area) {
		int w = (int) Math.sqrt(area);
		while (area % w != 0) {
			--w;
		}
		return new int[] { area / w, w };
	}

	public int[] constructRectangle1(int area) {
		int w = (int) Math.sqrt(area);
		int l = w;
		int a = w * l;
		while (a != area) {
			if (a > area) {
				w -= 1;
				l = area / w;
			} else {
				l += 1;
				w = area / l;
			}
			a = w * l;
		}
		return new int[] { l, w };
	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
